#include"TcpServer.hpp"
#include"Command.hpp"

#include <memory>
using namespace LogModule;

int main(int argc, char *argv[])
{
    ENABLE_CONSOLE_LOG();
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " localport" << std::endl;
        Die(USAGE_ERR);
    }
    // std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);

    std::shared_ptr<Command> command_service = std::make_shared<Command>();
    std::shared_ptr<TcpServer> server =std::make_shared<TcpServer>(std::stoi(argv[1]));

    server->InitServer();
    server->RegisterSerive(
        [&command_service](std::string cmdstr){
            return command_service->Execute(cmdstr);
        }

    );

    server->Start();

    return 0;
}